package footballtest;

/**
 * 踢球测试
 * 
 * 测试QQ宠物踢球的胜率
 * @author 	林岑
 * @time	2012年1月5日 14:00:40
 */
public class FootBallTest {
	
	

	public static void main ( String[] args ) {
		//25000元宝
		Person p = new Person();
		
		int ALL = 100000;
		int sum = 0;
		for (int i = 0; i < ALL; i++) {
			boolean isWin = play(p);
			sum += isWin ? 1 : 0;
		}
		System.out.println("win:" + sum );
		System.out.println("fai:" + (ALL - sum) );
	}

	private static boolean play ( Person p ) {
		boolean isWin = true;
		
		for (int i = 0; i < 100; i++) {
			if(isWin) {
				isWin = p.playBall(true);
			} else {
				playToWin1(p);
			}
		}
		return p.coins > 25000;
	}

	/**
	 * p
	 * 玩大, 直到赢一次
	 * @param p
	 */
	private static void playToWin1 ( Person p ) {
		p.playBall( false );
		p.playBall( false );
	}
}
